#!/bin/bash
# lib
# 2016-10-27

case $1 in
	start )
		/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf
		echo "starting zabbix_agentd..."
		sleep 5
		tail -n 1 /usr/local/zabbix/logs/zabbix_agentd.log
		;;
	stop )
		PID=$(cat /usr/local/zabbix/run/zabbix_agentd.pid)
		echo "stoping zabbix_agentd..."
		kill $PID
		sleep 5
		tail -n 1 /usr/local/zabbix/logs/zabbix_agentd.log
		;;
	restart )
		echo "stoping zabbix_agentd..."
		PID=$(cat /usr/local/zabbix/run/zabbix_agentd.pid)
		kill $PID
		sleep 5
		tail -n 1 /usr/local/zabbix/logs/zabbix_agentd.log
		echo "starting zabbix_agentd..."
		/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf
		sleep 5
		tail -n 1 /usr/local/zabbix/logs/zabbix_agentd.log
		;;
	* )
		echo "$0 {start|stop|restart|status}"
		exit 4
		;;
esac